
import { useState } from 'react';
import { BrowserRouter as Router } from 'react-router-dom'
import Routes from './router'
import { state, userContext } from './store/userContext';
const App = () => {
  // 1. 父组件定义状态(全局的context中的初始值+组件内定义的状态)
  // 2. 父组件定义修改全局context的方法fn
   const [userState, setUserState] = useState(state)
   const updateUserState = (state:any) => {
    console.log('全局的state', state)
    setUserState({
      ...userState,
      ...state
    })
   }

  return (
    <Router>
      <userContext.Provider value={{...userState, updateUserState}}>
        <Routes />
      </userContext.Provider>
    </Router>
  );
}
export default App;
